package com.zjc.yohoshop.mvp.view.adapter;

import android.util.Log;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zjc.yohoshop.R;
import com.zjc.yohoshop.bean.CreateOrderEntity;
import com.zjc.yohoshop.network.API;

/**
 * 订单适配器
 */
public class CreateOrderAdapter extends BaseQuickAdapter<CreateOrderEntity.ValuesBean, BaseViewHolder> {
    public CreateOrderAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, CreateOrderEntity.ValuesBean item) {
        helper.setText(R.id.tv_item_create_order_ordernum, item.goods_id);//订单编号
        Glide.with(helper.itemView.getContext()).load(API.BaseUrl + item.car_path).into((ImageView) helper.getView(R.id.iv_item_create_order_car_path));//图片
        helper.setText(R.id.tv_item_create_order_shop_name, item.shop_name);//商品名tv_item_create_order_shop_price
        helper.setText(R.id.tv_item_create_order_shop_price, "￥" + item.shop_price);//商品单价
        String color = "";
        if ("1".equals(item.shop_color)){
            color = "红色";
        }else if ("2".equals(item.shop_color)){
            color = "绿色";
        }else if ("3".equals(item.shop_color)){
            color = "白色";
        }else if ("4".equals(item.shop_color)){
            color = "黑色";
        }
        helper.setText(R.id.tv_item_create_order_shop_color, "颜色 : " + color);//颜色
        String size = "";
        if ("1".equals(item.shop_size)){
            size = "L";
        }else if ("2".equals(item.shop_size)){
            size = "XL";
        }else if ("3".equals(item.shop_size)){
            size = "XXL";
        }else if ("4".equals(item.shop_size)){
            size = "XXXL";
        }
        helper.setText(R.id.tv_item_create_order_shop_size, "尺码:" + size);//尺寸

        int sum = (Integer.parseInt(item.shop_price) * Integer.parseInt(item.shop_num));
        helper.setText(R.id.tv_item_create_order_shop_sumPrice, "￥" + sum);//总价

        helper.addOnClickListener(R.id.tv_item_create_order_delete, R.id.tv_item_create_order_add);
        Log.e(TAG, "周军成 -> " + item.shop_name );

    }
}
